
<div class="febs-container" id="baseProject-detail">
    <div class="febs-open-body">
        <div class="febs-table-full">
            <table lay-filter="userScoreDetailTable" lay-data="{id: 'userScoreDetailTable'}"></table>
        </div>
    </div>
</div>

<script data-th-inline="javascript" type="text/javascript">
    layui.use(['jquery', 'febs', 'form', 'table', 'commonJS', 'validate'], function () {
        var $ = layui.jquery,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            commonJS = layui.commonJS,
            validate = layui.validate,
            $view = $('#baseProject-detail'),
            tableIns;

        var tenantId = POPUP_DATA.tenantId;
        var userId = POPUP_DATA.userId;

        form.verify(validate);
        form.render();

        initTable();

        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'userScoreDetailTable',
                url: ctx + 'baseUserScoreRecord/list',
                height: getTableHeight(),
                where: getQueryParams(),
                skin: '',
                cols: [
                    [
                    {type: 'numbers', title: '序号'},
                    {field: 'realName', title: '用户姓名', width: 120,align:'center'},
                    {field: 'userNo', title: '用户工号', width: 120,align:'center'},
                    {field: 'deptName', title: '所属部门', width: 120,align:'center'},
                    {field: 'dataSource', title: '积分来源', width: 120 ,align:'center',templet:function (d){
                            let dataSourceName = '--'
                            switch (d.dataSource) {
                                case '1':
                                    dataSourceName = '事故管理';
                                    break;
                                case '2':
                                    dataSourceName = '违章管理';
                                    break;
                                case '3':
                                    dataSourceName = '隐患管理';
                                    break;
                                case '4':
                                    dataSourceName = '安全检查';
                                    break;
                                case '5':
                                    dataSourceName = '激励管理';
                                    break;
                                case '99':
                                    dataSourceName = '积分兑换';
                                    break;
                                default:
                                    break;
                            }
                            return dataSourceName;
                        }},
                    {field: 'operateType', title: '积分获取/消耗', width: 130 ,align:'center',templet:function (d){
                            if(d.operateType === '1'){
                                return  '<span class="layui-badge febs-tag-green" style="width: 22px;line-height: 15px">+</span>';
                            }else if (d.operateType === '2') {
                                return  '<span class="layui-badge febs-tag-red" style="width: 22px;line-height: 15px">-</span>';
                            }
                        }},
                    {field: 'operateScore', title: '获取/消耗积分', width: 130,align:'center'},
                    {field: 'beforeScore', title: '更新前积分', width: 120,align:'center'},
                    {field: 'afterScore', title: '更新后积分', width: 120,align:'center'},
                    {field: 'operateDate', title: '操作时间', width: 180,align:'center'},
                    {field: 'remark', title: '备注', minWidth: 120},

                ]],
            });
        }

        function getQueryParams() {
            return {
                tenantId: tenantId,
                userId: userId,
                invalidate_ie_cache: new Date()
            };

        }

        function getTableHeight() {
            return commonJS.calcTableHeight(100);
        }

        $(window).resize(function () {
            tableIns.reload({height: getTableHeight()});
        });
    });
</script>